
class Solution {
public:
    string addStrings(string num1, string num2) {
        string res = "";
        int i1 = num1.size()-1, i2 = num2.size()-1;
        int add = 0;
        while(i1 >= 0 || i2 >= 0 || add != 0){
            int a = i1 >= 0 ? num1[i1] - '0':0;
            int b = i2 >= 0 ? num2[i2] - '0':0;
            int c = a + b + add;
            res += c % 10 + '0';
            add = c / 10;
            i1--;
            i2--;
        }
        reverse(res.begin(), res.end());
        return res;
    }
};
